﻿using FireChat.Client.Session.Receiver;
using FireChat.Share.Web.Actions;
using FireChat.Share.Web.Model.Enums;
using FireChat.Share.Web.Model.Query.Contacts;
using FireChat.Share.Web.Package;

namespace FireChat.Client.Session.Manager;


/// <summary>
/// 事件管理类
/// </summary>
public static class ContactsManager
{
    /// <summary>
    /// 申请滚添加好友
    /// </summary>
    /// <param name="username">目标送用户名</param>
    public static async Task<IResponse> ApplyFriendsAsync(this ClientCore client, string username)
    {
        ApplyFriendQuery data = new()
        {
            Username = username
        };

        var package = ServertActions.ApplyFriend.CreatePackage(data);
        return await client.SendReceiveAsync(package);
    }

    /// <summary>
    /// 删除好友
    /// </summary>
    /// <param name="username">目标送用户名</param>
    public static async Task<IResponse> DeleteFriendAsync(this ClientCore client, string username)
    {
        DeleteFriendQuery data = new()
        {
            Username = username
        };

        var package = ServertActions.DeleteFriend.CreatePackage(data);
        return await client.SendReceiveAsync(package);
    }

    /// <summary>
    /// 同意好友请求
    /// </summary>
    /// <param name="username">目标送用户名</param>
    public static async Task<IResponse> AgreeFriendAsync(this ClientCore client, string username)
    {
        DeleteFriendQuery data = new()
        {
            Username = username
        };

        var package = ServertActions.ArgeeFriendApply.CreatePackage(data);
        return await client.SendReceiveAsync(package);
    }
}